'use strict';

import React, {
  Component
} from 'react';
import {
  Dimensions,
  Animated,
  InteractionManager,
} from 'react-native';

import TabsView from '../containers/TabsView';

const {
  height,
  width
} = Dimensions.get('window');
const splashImg = require('../img/splash.png');

class Splash extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      bounceValue: new Animated.Value(1)
    };
  }

  componentDidMount() {
    //启动动画
    Animated.timing(
      this.state.bounceValue, {
        toValue: 1.2,
        duration: 1000
      }
    ).start();
    //定时跳转
    this.timer = setTimeout(() => {
      const {
        navigator
      } = this.props;
      InteractionManager.runAfterInteractions(() => {
        navigator.resetTo({
          component: TabsView,
          name: 'TabsView'
        });
      });
    }, 1000);
  }

  render() {
    return ( < Animated.Image style = {
        {
          width: width,
          height: height,
          transform: [{
            scale: this.state.bounceValue
          }]
        }
      }
      source = {
        splashImg
      }
      />
    );
  }
}
export default Splash;